//
//  LXRequstBottomView.m
//  TuDianEducation
//
//  Created by lixinkeji on 2020/6/29.
//  Copyright © 2020 zhangbenchao. All rights reserved.
//
#import "LXRequstBottomView.h"
#import "LXOrderMessageValueItemView.h"
@interface LXRequstBottomView()
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) LXOrderMessageValueItemView *orderNumView;
///复制按钮
@property (nonatomic,strong) UIButton *copBtn;
@property (nonatomic,strong) LXOrderMessageValueItemView *createTimeView;
@property (nonatomic,strong) LXOrderMessageValueItemView *payTimeView;

@property (nonatomic,strong) LXOrderMessageValueItemView *fahuoTimeView;

@property (nonatomic,strong) LXOrderMessageValueItemView *finishTimeView;


@property (nonatomic,strong) UIButton*contactBtn;
@end
@implementation LXRequstBottomView
-(instancetype)init{
    if (self = [super init]) {
        [self viewConfig];
    }
    return self;
}
-(void)viewConfig{
    self.frame = CGRectMake(TSScaleW(11), 0, TSScreenWidth - TSScaleW(22), TSScaleW(100));
    self.backgroundColor = kWhiteColor;
    self.cornerRadius = TSScaleW(8);
    [self addSubview:self.titleLabel];
    [self addSubview:self.orderNumView];
    [self addSubview:self.createTimeView];
    [self addSubview:self.payTimeView];
    [self addSubview:self.fahuoTimeView];
    [self addSubview:self.finishTimeView];
    
 
    [self addSubview:self.contactBtn];
    self.height = self.contactBtn.bottom;
}
-(UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [TSWLTools allocLabel:@"订单信息" font:systemBoldFont(TSScaleW(15)) textColor:kMainTxtColor frame:CGRectMake(TSScaleW(11), TSScaleW(13), TSScaleW(200), TSScaleW(40)) textAlignment:(NSTextAlignmentLeft)];

    }
    return _titleLabel;
}
- (LXOrderMessageValueItemView *)orderNumView{
    if (!_orderNumView) {
        _orderNumView = [[LXOrderMessageValueItemView alloc]initWithTop:_titleLabel.bottom titleString:@"订单号" valueString:@"20200542010152461" isRedValue:NO];
        _orderNumView.valueLabel.right = _orderNumView.width - TSScaleW(30);
        _copBtn = [TSWLTools allocButtonTitle:@"" font:systemFont(0) textColor:kWhiteColor image:[UIImage imageNamed:@"复制"] frame:CGRectMake(_orderNumView.valueLabel.right, 0, TSScaleW(30), _orderNumView.height) sel:@selector(copyOrderAction:) taget:self];
        [_orderNumView addSubview:_copBtn];
    }
    return _orderNumView;
}
-(void)copyOrderAction:(UIButton *)sender
{
    [MBProgressHUD showError:SSKJLanguage(@"复制成功")];
       UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
       pasteboard.string =  _orderNumView.valueLabel.text;
}
-(LXOrderMessageValueItemView *)createTimeView{
    if (!_createTimeView) {
        _createTimeView = [[LXOrderMessageValueItemView alloc]initWithTop:_orderNumView.bottom titleString:@"创建时间" valueString:@"2020/05/04 20:10:15" isRedValue:NO];
    }
    return _createTimeView;
}
-(LXOrderMessageValueItemView *)payTimeView{
    if (!_payTimeView) {
        _payTimeView = [[LXOrderMessageValueItemView alloc]initWithTop:_createTimeView.bottom titleString:@"付款时间" valueString:@"2020/05/04 20:10:15" isRedValue:NO];
       
    }
    return _payTimeView;
}

-(LXOrderMessageValueItemView *)fahuoTimeView{
    if (!_fahuoTimeView) {
        _fahuoTimeView = [[LXOrderMessageValueItemView alloc]initWithTop:_payTimeView.bottom titleString:@"确认完成时间" valueString:@"2020/05/04 20:10:15" isRedValue:NO];
        
    }
    return _fahuoTimeView;
}
-(LXOrderMessageValueItemView *)finishTimeView{
    if (!_finishTimeView) {
        _finishTimeView = [[LXOrderMessageValueItemView alloc]initWithTop:_fahuoTimeView.bottom titleString:@"完成时间" valueString:@"2020/05/04 20:10:15" isRedValue:NO];
       
    }
    return _finishTimeView;
}


-(UIButton *)contactBtn{
    if (!_contactBtn) {
        _contactBtn = [TSWLTools allocButtonTitle:@"联系卖家" font:systemFont(TSScaleW(14)) textColor:kMainTxtColor image:[UIImage imageNamed:@"lianximaijia"] frame:CGRectMake(0, _finishTimeView.bottom, self.width, TSScaleW(42)) sel:@selector(contactBtnAction:) taget:self];
        [_contactBtn setTitleEdgeInsets:UIEdgeInsetsMake(0,TSScaleW(10), 0, 0)];
    }
    return _contactBtn;
}
-(void)contactBtnAction:(UIButton *)sender
{
    !self.ensureBtnBlock?:self.ensureBtnBlock();
}

-(void)setModel:(LXRequstOrderDetailModel *)model{
    _model = model;
    _orderNumView.valueLabel.text = _model.ordernum;
    _createTimeView.valueLabel.text = _model.adtime;
    _payTimeView.valueLabel.text = _model.paytime;
    _fahuoTimeView.valueLabel.text = _model.sendtime;
    _finishTimeView.valueLabel.text = _model.shtime;
    
}
@end
